package demo;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
public  class Heying{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()){
            int n = sc.nextInt();
            System.out.println(n + "人合影");
            Set<Double> boySet=new TreeSet<Double>();
            Set<Double> girlsSet=new TreeSet<Double>();
            girlsSet = ((TreeSet<Double>) girlsSet).descendingSet();
            for (int i =0;i<n;i++){
                String input=sc.next();
                if(input.equals("male"))
                    boySet.add(sc.nextDouble());
                if(input.equals("female"))
                    girlsSet.add(sc.nextDouble());
            }
            for(Double i:boySet) {
                System.out.printf("%.2f ",i);
            }
            for(Double i:girlsSet) {
                System.out.printf("%.2f ",i);
            }
        }
    }

}
